#include <iostream>
#include <unistd.h>
int main() {
    int ret;
    std::cout<<"系统分配的进程号为: "<<getpid()<<"\n";
    ret = system("ping www.baidu.com -c 4");
    if(-1 == ret)
    {
        std::cout<<"创建进程失败"<<"\n";
        return -1;
    }
    else if(127 == ret)
    {
        std::cout<<"函数执行失败"<<"\n";
    }
    else
    {
        std::cout<<"创建进程成功 "
                   <<"父进程id："<<getppid()
                   <<"子进程id:"<<getpid()<<"\n";
    }
    return 0;
}